#!/usr/bin/env python
'''
1、需要得到此结果：使用while循环输入 1 2 3 4 5 6 8 9 10
'''
# 方法一：
# count = 0
# while count < 10:
#     count += 1
#     if count == 7:
#         pass   #pass与continue的区别在此
#     else:
#         print(count,end=' ')

# 方法二：特点：代码数量少，使用第二种方法
# count = 0
# while count < 10:
#     count += 1
#     if count == 7:
#         continue
#     print(count,end=' ')

'''
2、求1-100的所有数的和
'''
# sum = 0
# for i in range(1,101):
#     sum += i
# print(sum)
'''
3、求1-100的所有奇数的和
'''
# 方法一：
# sum = 0
# for i in range(1,101):
#     if i % 2 == 1:
#         sum += i
# print(sum)
# 方法二：
# sum = 0
# count = 1
# while count < 100:
#     sum += count
#     count += 2
# print(sum)
'''
4、求1-100的所有偶数的和
'''
# sum = 0
# for i in range(1,101):
#     if i % 2 == 0:
#         sum += i
# print(sum)
'''
5、求1-2+3-4+5...99的所有数的和
'''
# sum = 0
# for i in range(1,100):
#     if i % 2 == 0:
#         sum -= i
#     else:
#         sum += i
# print(sum)
'''
6、用户登陆(三次机会重试)
'''
i = 0
while i < 3:
    user = input("请输入用户名：")
    pwd = input("请输入密码：")
    if user == 'wang' and pwd == '123456':
        print("登陆成功")
        break
    else:
        print(f"用户名{user}或密码{pwd}输入错误，请重新输入")
    i += 1
    print(f"已经输入了{i}次")